package com.gaga.console.base.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @author liujia
 * @version 1.0
 * @date 2022/8/8 13:26
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {

    @Bean(value = "defaultSys")
    public Docket defaultSys() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .version("1.0")
                        .build())
                //分组名称
                .groupName("系统模块")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.gaga.console.core.controller.sys"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    @Bean(value = "defaultCommon")
    public Docket defaultCommon() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .version("1.0")
                        .build())
                //分组名称
                .groupName("通用模块")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.gaga.console.core.controller.common"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }


    @Bean(value = "defaultAccount")
    public Docket defaultAccount() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .version("1.0")
                        .build())
                //分组名称
                .groupName("账户管理")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.gaga.console.core.controller.account"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }


    @Bean(value = "defaultApp")
    public Docket defaultApp() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .version("1.0")
                        .build())
                //分组名称
                .groupName("APP模块")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.gaga.console.core.controller.app"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }


}
